<?php
// -----------------------------------------------------------------------------
// ------------------------------- Configuration -------------------------------
// -----------------------------------------------------------------------------

// Set development mode
define('DEVELOPMENT', true);

// Separators
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);

// You do not have to change these paths except you want your core to be somewhere else
// Path defines
define('PATH_DIR',					__DIR__.DS);
define('PATH_BASE',					'.'.DS);
define('PATH_APP',					PATH_BASE.'app'.DS);
define('PATH_APP_CODE',				PATH_BASE.'app'.DS.'code'.DS);
define('PATH_APP_ETC',				PATH_BASE.'app'.DS.'etc'.DS);
define('PATH_APP_ETC_MODULES',		PATH_BASE.'app'.DS.'etc'.DS.'modules'.DS);
define('PATH_APP_LIBRARY',			PATH_BASE.'app'.DS.'library'.DS);
define('PATH_APP_TEMPLATE',			PATH_BASE.'app'.DS.'template'.DS);
define('PATH_DESIGN',				PATH_BASE.'design'.DS);
define('PATH_DESIGN_MEDIA',			PATH_BASE.'design'.DS.'media'.DS);
define('PATH_DESIGN_SKIN',			PATH_BASE.'design'.DS.'skin'.DS);
define('PATH_VAR',					PATH_BASE.'var'.DS);
define('PATH_VAR_CACHE',			PATH_BASE.'var'.DS.'cache'.DS);
define('PATH_VAR_SESSION',			PATH_BASE.'var'.DS.'session'.DS);
define('ZEUS_FILE',					PATH_APP.'Zeus.php'); // Define Zeus main file location



// -----------------------------------------------------------------------------
// -------------------------------   Run  Zeus   -------------------------------
// -----------------------------------------------------------------------------

// Try everything to provide an exception handler for every error
try {
	// Get the include path for all relevant files
	$paths = array();
	$paths[] = PATH_APP_CODE.'local';
	$paths[] = PATH_APP_CODE.'community';
	$paths[] = PATH_APP_CODE.'core';
	$paths[] = PATH_APP_LIBRARY;
	$includePath = get_include_path().PS.implode(PS, $paths);

	// Set the include path
	set_include_path($includePath);

	// Include development functions
	require_once('ZeusLib/development.php');

	// Include autoload, security and essential functions
	// This file also registers the error handler and the autoload function
	require_once("ZeusLib/functions.php");

	// Check whether Zeus main file not exists
	if(!file_exists(ZEUS_FILE))
	{
		// Check whether the installer exists
		if(is_dir('installer'))
		{
			// Locate to the installer
			header('Location: '.PATH_BASE.'installer');
			// TODO
		}
		else
		{
			// Print and error
			echo ZEUS_FILE." was not found";
		}

		// Exit script
		exit(1);
	}

	// Require the zeus file
	require_once(ZEUS_FILE);

	// Run Zeus normal
	Zeus::run(Zeus::ZEUS_RUN);
}
// Catch error exception for special error handling
catch(ErrorException $e)
{
	// TODO
	throw new ToDo("ErrorException");
}
// Catch general exception exception
catch(Exception $e)
{
	// Display the exception
	exceptionHandler($e);
}

// Exit script for security reasons
exit(0);